package com.cet.qz.unit01.chapter1_3;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-04-06 21:26
 **/
public class IterableStack {

    public static Stack<String> copy(Stack<String> stack) {

        Stack<String> copies = new Stack<>();

        Stack<String> tmp = new Stack<>();

        for (String s : stack) {
            tmp.push(s);
        }

        for (String s : tmp) {
            copies.push(s);
        }

        return copies;
    }

    public static void main(String[] args) {
        Stack<String> stack = new Stack<>();
        stack.push("a");
        stack.push("b");
        stack.push("c");
        stack.push("d");
        stack.push("e");
        for (String s : copy(stack)) {
            System.out.println(s);
        }
    }
}
